<?php
check_login();
class AdminAction extends Action{
	public function index(){
		$rs=pageing('admin',10,'',$_GET['seach'],'id desc','1','username');
		$this->assign('rs',$rs);
		$this->display();
	}
	public function add_admin(){
		$rs=M('admin')->add($_POST);
		if($rs)
			$this->success('添加成功');
		else
			$this->error('添加失败');
	}
	public function del_admin(){
		$rs=D('Public')->del_data('admin',$_GET['id']);
		if($rs){
			echo json_encode(array('code'=>1,'msg'=>'删除成功'));	
		}else{
			echo json_encode(array('code'=>0,'msg'=>'删除失败'));
		}	
	}
	public function to_upt(){
		$rs=D('Public')->get_one('admin',$_GET['id']);	
		$this->assign('rs',$rs);
		$this->display();
	}
	public function uptAct(){
		$rs=D('Public')->upt_date('admin',$_POST['id'],$_POST);
		if($rs){
			echo json_encode(array('code'=>1,'msg'=>'修改成功'));	
		}else{
			echo json_encode(array('code'=>0,'msg'=>'修改失败'));	
		}
	}
}
?>